import {HttpHelper} from "./HttpHelper";
import {Injectable} from "@angular/core";
import {ManufactureForm} from "./domains";

@Injectable()
export class ManufactureFormService {

    constructor(private httpHelper: HttpHelper) {}

    getManufactureForms(page,size,name) : Promise<ManufactureForm[]>{

        let url = `forms/?page=${page}&size=${size}`;
        if (name) {
            url = url + `&name=${name}`;
        }
        return this.httpHelper.getJson<ManufactureForm[]>(url);
    }

    addManufacureForm(name) : Promise<boolean> {
        let url = `forms/?name=${name}`;
        return this.httpHelper.postToBoolean(url,null);
    }

    updateManufacutreForm() : Promise<boolean> {
        let url = `forms`;
        return this.httpHelper.putToBoolean(url,null);
    }
}
